<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript" src="{JS_PATH}jquery.min.js"></script>

<link type="text/css" rel="stylesheet" href="{CSS_PATH}table_form.css">	
<link type="text/css" rel="stylesheet" href="{CSS_PATH}zsask/zsask.css">

<title>问答分类</title>
</head>
<body>
<div class="bg"> 选择分类：<span id="cpath"></span></div>
<div class="type">

<div class="select_type">
<table class="table_form" cellspacing="0">
<tbody id="grade_1">
{loop $askcategorys $r}
{if $r[grade] ==1 && $r[status] ==99}
<tr class="pointer" onclick="selected('{$r[catid]}', 1, '{$r[catname]}', this)"><td>
{$r[catname]}
</td></tr>
{/if}
{/loop}
</tbody>
</table>
</div>

<div class="select_type">
<table class="table_form" cellspacing="0">

<tbody id="grade_2">

<tr><td>
</td></tr>

</tbody>

</table>
</div>

<div class="select_type" cellspacing="0">
<table class="table_form">

<tbody id="grade_3">

<tr><td>
</td></tr>

</tbody>

</table>
</div>
<input type="hidden" name="_cid" id="select_catid" value="0" />
</div>


<script type="text/javascript">
	function selected(cid, grade, catname, obj) {
		var cpath = '';
		for (i =grade; i<4; i++) {
			$('#grade_'+ i +' tr').removeClass('tbg');
			$('#grade_'+ (i+1)).html('');
		}
		$(obj).addClass('tbg');
		$.get('?m=zsask&a=select_type&cid='+ cid, 
			function (data){
				if (data =="1") {
					$("tbody .tbg").each(function(j, n){//分类路径
						cpath += $(".tbg:eq("+ j +") td").html() + ' >> ';
					});
					$('#cpath').html(cpath);
					$('#select_catid').val(cid);
				} else{
					$("tbody .tbg").each(function(j, n){//分类路径
						cpath += $(".tbg:eq("+ j +") td").html() + ' >> ';
					});
					$('#cpath').html(cpath);
					$('#grade_'+ (grade+1)).html(data);
				}
			}
		);
	}
</script>

</body>
</html>